package org.example.helloworld.controller;

import org.example.helloworld.entity.History;
import org.example.helloworld.entity.Home;
import org.example.helloworld.service.IHomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RequestMapping("/home")
@RestController
public class HomeController {

    @Autowired
    private IHomeService homeService;

    @GetMapping
    public List<Home> getAllRates() {
        return homeService.list();
    }

    @GetMapping("/{id}")
    public Home getRateById(@PathVariable String id) {
        return homeService.getById(id);
    }

    @PostMapping
    public boolean addRate(@RequestBody Home rate) {
        return homeService.save(rate);
    }

    @PutMapping
    public boolean updateRate(@RequestBody Home rate) {
        return homeService.updateById(rate);
    }

    @DeleteMapping("/{id}")
    public boolean deleteRate(@PathVariable String id) {
        return homeService.removeById(id);
    }

}